import { Component } from '@angular/core';
import { NavController, NavParams } from 'ionic-angular';
import { HttpService } from '../../../service/httpService';
import { UserService } from '../../../service/userService';
import { NativeService } from '../../../service/NativeService';
@Component({
  selector: 'page-history',
  templateUrl: 'history.html',
})
export class HistoryPage {
  private title:string;
  private url:string;
  private dataSource:any;
  private showLoading = true;
  constructor(public navCtrl: NavController,
              public http:HttpService,
              public user:UserService,
              public nat:NativeService,
              public navParams: NavParams) {
    let title = navParams.get("title");
    this.title = title;

    if(title == '取款记录'){
      this.url = "/api/Withdrawal/GetWithdrawalList";
    }else if(title == "存款记录"){
      this.url = "/api/Deposit/GetDepositList";
    }else if(title == "转账记录"){
      this.url = "/api/Transfer/GetTransferList";
    }
    this.getData();
  }


  getData(){

    var map = {};

    if(this.title == '取款记录'){
      map = {
        status:'',
        beginTime:'',
        endTime:'',
        pageIndex:0,
        pageSize:30,
      };
    }else if(this.title == "存款记录"){
      map = {
        type:'',
        status:'',
        beginTime:'',
        endTime:'',
        pageIndex:0,
        pageSize:30,
      };
    }else if(this.title == "转账记录"){
      map = {
        type:'',
        status:'',
        beginTime:'',
        endTime:'',
        pageIndex:0,
        pageSize:30,
        gamePlatform:''
      };
    }


    let self = this;
    this.http.get(this.url,map,function (res,err) {
      self.showLoading = false;
      if(!err){
        console.log(res);
        self.dataSource = res.list;
      }
    })



  }

}
